package com.main.modulemysql.web;


import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.main.modulemysql.config.ChartData;
import com.main.modulemysql.entity.GatewayApiDefine;
import com.main.modulemysql.service.IGatewayApiDefineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author IceZhang
 * @since 2018-08-03
 */
@Api(tags = "gateway control")
@RestController
@RequestMapping(value = "/test",method = RequestMethod.GET)
public class GatewayApiDefineController {

    @Autowired
    IGatewayApiDefineService gatewayApiDefineService;

    @ApiOperation(value="获取路由数量", notes="根据url的id来获取用户详细信息")
    @RequestMapping("/test")
    @ResponseBody
    public String test(){

        EntityWrapper<GatewayApiDefine>entityWrapper=new EntityWrapper<GatewayApiDefine>();
        entityWrapper.like("id","baiu");
        int i = gatewayApiDefineService.selectCount(entityWrapper);
        return i+"";

    }

    @ApiOperation(value="获取路由分页列表", notes="根据url的id来获取用户详细信息")
    @RequestMapping("/page")
    @ResponseBody
    public String page(){
        Page<GatewayApiDefine>page=new Page<>(1,10);

        Page<GatewayApiDefine> gatewayApiDefinePage = gatewayApiDefineService.selectPage(page);
        return JSON.toJSONString(gatewayApiDefinePage);

    }
    @ApiOperation(value = "报表测试",notes = "报表测试接口")
    @RequestMapping("/charts")
    @ResponseBody
    public String chart(){

        List<ChartData>list=new ArrayList<>();

        for(int i=0;i<10;i++){
            ChartData chartData = new ChartData();
            chartData.setDate(i+"");
            chartData.setValue(i+"");
            list.add(chartData);
        }
        return JSON.toJSONString(list);
    }


}

